package com.lms.dao;

import com.lms.bean.Book;
import com.lms.bean.Type;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TypeDao extends JpaRepository<Type, Long>, JpaSpecificationExecutor<Type> {
    @Query("select t from Type t")
    List<Type> getList(Pageable pageable);

    @Query("select t from Type t where t.typeId=?1 or t.typename like ?2")
    List<Type> findAllByTypeIdOrTypenameLikePage(Long typeId, String typename,Pageable pageable);

    @Query("select t from Type t where t.typename like ?1")
    List<Type> findAllByTypenameLikePage(String typename,Pageable pageable);

    Long countAllByTypeIdOrTypenameLike(Long typeId, String typename);

    Long countAllByTypenameLike(String typename);


}
